import re
from django.db.models import Prefetch
from user.models import *

from rest_framework import filters
from rest_framework import mixins
from rest_framework import permissions
from rest_framework import viewsets
from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.parsers import MultiPartParser, FileUploadParser

from django_filters.rest_framework import DjangoFilterBackend

from tool import restful
from tool.paginations import CommonPagination
from user.models import *
from .models import *
from .serializers import *
from rewrite.my_modelviewset import MyModelViewSet
from rewrite.my_mixins import MyListModelMixin, MyCreateModelMixin

# 事件图片
class EventImgViewSet(MyModelViewSet):
    """
    事件图片
    """
    queryset = EventImg.objects.filter(deleted__exact='0')            # 对应模型数据集和
    serializer_class = EventImgSerializer                             # 经过序列化器
    permission_classes = [permissions.IsAuthenticated]              # 权限限制
    pagination_class = CommonPagination                             # 分页

# 事件图片下拉选
class EventImgOptionViewSet(MyModelViewSet):
    """
    事件图片下拉选
    """
    queryset = EventImg.objects.filter(deleted__exact='0')            # 对应模型数据集和
    serializer_class = EventImgOptionSerializer                             # 经过序列化器
    permission_classes = [permissions.IsAuthenticated]              # 权限限制
    pagination_class = CommonPagination                             # 分页

# 事件类型
class EventTypeViewSet(MyModelViewSet):
    """
    事件类型
    """
    queryset = EventType.objects.filter(deleted__exact='0')            # 对应模型数据集和
    serializer_class = EventTypeSerializer                             # 经过序列化器
    permission_classes = [permissions.IsAuthenticated]              # 权限限制
    pagination_class = CommonPagination                             # 分页

# 事件类型下拉选
class EventTypeOptionViewSet(MyModelViewSet):
    """
    事件类型下拉选
    """
    queryset = EventType.objects.filter(deleted__exact='0')            # 对应模型数据集和
    serializer_class = EventTypeOptionSerializer                             # 经过序列化器
    permission_classes = [permissions.IsAuthenticated]              # 权限限制
    pagination_class = CommonPagination                             # 分页

# 评论
class CommentViewSet(MyModelViewSet):
    """
    评论
    """
    queryset = Comment.objects.filter(deleted__exact='0')            # 对应模型数据集和
    serializer_class = CommentSerializer                             # 经过序列化器
    permission_classes = [permissions.IsAuthenticated]              # 权限限制
    pagination_class = CommonPagination                             # 分页

# 评论下拉选
class CommentOptionViewSet(MyModelViewSet):
    """
    评论下拉选
    """
    queryset = Comment.objects.filter(deleted__exact='0')            # 对应模型数据集和
    serializer_class = CommentOptionSerializer                             # 经过序列化器
    permission_classes = [permissions.IsAuthenticated]              # 权限限制
    pagination_class = CommonPagination                             # 分页

# 事件
class EventViewSet(MyModelViewSet):
    """
    事件
    """
    queryset = Event.objects.filter(deleted__exact='0')            # 对应模型数据集和
    serializer_class = EventSerializer                             # 经过序列化器
    permission_classes = [permissions.IsAuthenticated]              # 权限限制
    pagination_class = CommonPagination                             # 分页